# Color
set-option -sa terminal-overrides ",xterm*:Tc"

# Basic
set -g mouse off
set -g base-index 1
set -g pane-base-index 1

# Configure the catppuccin plugin
set -g @catppuccin_flavor "frappe"
set -g @catppuccin_window_status_style "rounded"
set -ogq @catppuccin_window_text " #W"
set -ogq @catppuccin_window_current_text " #W"
# Load catppuccin
run '~/.tmux/plugins/tmux/catppuccin.tmux'
# Make the status line pretty and add some modules
set -g status-right-length 100
set -g status-left-length 0
set -g status-left ""
set -g status-right "#{E:@catppuccin_status_session}"
set -ag status-right "#{E:@catppuccin_status_uptime}"
set -agF status-right "#{E:@catppuccin_status_battery}"

# Yazi file manager
# Reference: https://yazi-rs.github.io/docs/image-preview/#tmux
set -g allow-passthrough on
set -ga update-environment TERM
set -ga update-environment TERM_PROGRAM

# Modify prefix key
unbind C-b
set -g prefix C-z
# Send `C-z` to shell or sub-tmux
bind C-z send-prefix

# Copy buffer to System's clipboard
bind C run-shell "tmux show-buffer | clipcopy"

# Reload tmux configuration
bind r source-file ~/.tmux.conf \; display "Reload!"

bind | split-window -h
bind - split-window -v

unbind [
unbind ]
bind [ previous-window
bind ] next-window

# Vim-mode
set -g mode-keys vi
set -sg escape-time 1
bind Escape copy-mode
bind -T copy-mode-vi v send-keys -X begin-selection
bind -T copy-mode-vi y send-keys -X copy-selection-and-cancel
unbind p
bind p paste-buffer

bind -r h select-pane -L
bind -r j select-pane -D
bind -r k select-pane -U
bind -r l select-pane -R

bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5

#set-option -g default-shell /bin/bash
# Tmux uses login shell default, this will case that $PATH is unexcepted
# https://github.com/tmux/tmux/issues/2972
set-option -g default-command /bin/zsh

#set -g @cpu_percentage_format "%2.0f%%"
# Tmux Plugin Manager(TPM)
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-battery'
set -g @plugin 'tmux-plugins/tmux-cpu'
set -g @plugin 'tmux-plugins/tmux-prefix-highlight'
set -g @plugin 'tmux-plugins/tmux-sensible'
#set -g @plugin 'catppuccin/tmux#v2.1.3'
# Initialize TMUX plugin manager
run '~/.tmux/plugins/tpm/tpm'
